<?php

use Illuminate\Support\Facades\Route;

Auth::routes(['verify'=>true]);
//首页
Route::group(['namespace'=>'Index'], function() {
    Route::get('/', 'IndexController@root')->name('root');
    Route::get('statuses', 'IndexController@statuses')->name('statuses');
    Route::group(['namespace'=>'Users'], function() {
        Route::resource('users', 'UsersController');
        Route::get('/users/{user}/followings', 'UsersController@followings')->name('users.followings');
        Route::get('/users/{user}/followers', 'UsersController@followers')->name('users.followers');
        //收货地址
        Route::get('user_addresses', 'UserAddressesController@index')->name('user_addresses.index');
        Route::get('user_addresses/create', 'UserAddressesController@create')->name('user_addresses.create');
        Route::post('user_addresses', 'UserAddressesController@store')->name('user_addresses.store');
        Route::get('user_addresses/{user_address}', 'UserAddressesController@edit')->name('user_addresses.edit');
        Route::put('user_addresses/{user_address}', 'UserAddressesController@update')->name('user_addresses.update');
        Route::delete('user_addresses/{user_address}', 'UserAddressesController@destroy')->name('user_addresses.destroy');
    });
});
//每日一句
Route::group(['namespace'=>'Community'], function() {
    //文章
    Route::group(['namespace'=>'Statuses'], function() {
        Route::resource('shared', 'StatusesController', ['only' => ['store', 'destroy']]);
    });
    //粉丝
    Route::group(['namespace'=>'Follower'], function() {
        Route::post('/users/followers/{user}', 'FollowersController@store')->name('followers.store');
        Route::delete('/users/followers/{user}', 'FollowersController@destroy')->name('followers.destroy');
    });

});
//话题
Route::group(['namespace'=>'Topic'], function() {
    Route::group(['namespace'=>'Categories'], function() {
        Route::resource('categories', 'CategoriesController', ['only' => ['show']]);
    });
    Route::group(['namespace'=>'Topic'], function() {
        Route::resource('topics', 'TopicsController', ['only' => ['index', 'create', 'store', 'update', 'edit', 'destroy']]);
        Route::get('topics/{topic}/{slug?}', 'TopicsController@show')->name('topics.show');
        Route::post('upload_image', 'TopicsController@uploadImage')->name('topics.upload_image');
    });
    Route::group(['namespace'=>'Reply'], function() {
        Route::resource('replies', 'RepliesController', ['only' => ['store', 'destroy']]);
    });
    Route::group(['namespace'=>'Notice'], function() {
        Route::resource('notifications', 'NotificationsController', ['only' => ['index']]);
    });
});
Route::group(['namespace'=>'Goods'], function() {
    Route::get('products/favorites', 'ProductsController@favorites')->name('products.favorites');
    Route::get('products', 'ProductsController@index')->name('products.index');
    Route::get('products/{product}', 'ProductsController@show')->name('products.show');
    Route::post('products/{product}/favorite', 'ProductsController@favor')->name('products.favor');
    Route::delete('products/{product}/favorite', 'ProductsController@disfavor')->name('products.disfavor');
    Route::group(['namespace'=>'Order'], function() {
        //购物车

        Route::post('cart', 'CartController@add')->name('cart.add');
        Route::get('cart', 'CartController@index')->name('cart.index');
        Route::delete('cart/{sku}', 'CartController@remove')->name('cart.remove');
        //下单
        Route::post('orders', 'OrdersController@store')->name('orders.store');
        Route::get('orders', 'OrdersController@index')->name('orders.index');
        Route::get('orders/{order}', 'OrdersController@show')->name('orders.show');
    });
    //支付
    Route::group(['namespace'=>'Pay'], function() {
        Route::get('payment/{order}/alipay', 'PaymentController@payByAlipay')->name('payment.alipay');
        Route::get('payment/alipay/return', 'PaymentController@alipayReturn')->name('payment.alipay.return');
        Route::post('payment/alipay/notify', 'PaymentController@alipayNotify')->name('payment.alipay.notify');
    });
});
Route::get('alipay', function() {
    return app('alipay')->web([
        'out_trade_no' => time(),
        'total_amount' => '1',
        'subject' => 'test subject - 测试',
    ]);
});
//登录_注册
Auth::routes();
//用户



